home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!qp7
- From: qp7@teleport.com (QP7)
- Newsgroups: comp.lang.c++
- Subject: Re: DOS Like Pipe Operator In C++??
- Date: 18 Mar 1996 03:04:21 GMT
- Organization: SHATTERED PERSPECTIVES GAMES
- Message-ID: <4iijrl$ept@nadine.teleport.com>
- References: <4iffh3$p01@netaxs.com>
- NNTP-Posting-Host: ip-pdx01-32.teleport.com
- X-Newsreader: News Xpress Version 1.0 Beta #3
-
- In article <4iffh3$p01@netaxs.com>, rvaughn@pacsibm.org (RussellMania) wrote:
- >class world {
- > int x;
- > public:
- > world(int a) { x = a; }
- > void set(int xx) { x = xx; }
- >};
- >class hello {
- > int x;
- > world view; // define an object as a private member
- > public:
- > void set(int x) { view.set(x); } // set function
- > int y; // data member
- > hello(int z):view(z) { x = 57; y = 66; } // constructor??
- > void display() {cout << x << " " << y << '\n'; view.display(;}
- >};
- >void main(void)
- >{ hello peace(55); peace.display(); }
- >Outputs are 57 66
- > and 55
- >Is the : character in the constructor of class hello acting as
- >a pipe? Thanks again for all replies...Russell
-
- You mean like an OR pipe? No. This line is the constructor for the hello
- class, which accepts an integer (z) initializer. The class view is being
- initialized when hello is. All that you're doing here is initializing view
- with the initializer passed to hello. Another way of writing this constructor
- is:
-
- hello(int z) {
- view(z);
- x = 57; y = 66;
- }
-
- You get the same effect, but it's better to intialized encapsulated classes
- from the constructor using this initializer list. You can also intialize data
- members using the exact same method.
-
- - QP7 -
-
- ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
- - Marcus Litchfield
- - qp7@teleport.com
- - http://www.teleport.com/~qp7
- ( |_)
- )hattered | erspectives
- [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
-